package com.itheima.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;

//接收端
public class SockdetDemoZuBo02 {
    public static void main(String[] args) throws IOException {
        MulticastSocket mu = new MulticastSocket(8080);
        byte[] bytes = new byte[1024];
        DatagramPacket da = new DatagramPacket(bytes, bytes.length);
        mu.joinGroup(InetAddress.getByName("224.0.0.3"));
        mu.receive(da);
        byte[] data = da.getData();
        int length = da.getLength();
        System.out.println(new String(data, 0, length));
        mu.close();

    }
}

